import 'package:floor/floor.dart';

import '../entity/group_member.dart';

@dao
abstract class GroupMemberDao {
  @Query('SELECT * FROM GroupMemberEntity')
  Future<List<GroupMemberEntity>> findAllPersons();

  @Query('SELECT * FROM GroupMemberEntity WHERE id = :id')
  Stream<GroupMemberEntity?> findGroupMemberById(int id);

  @Query('select * from GroupMemberEntity where userId = :uid')
  Future<List<GroupMemberEntity>> findGroupByUserId(int uid);

  @insert
  Future<void> insertGroupMember(GroupMemberEntity groupMember);

  @insert
  Future<void> insertGroupMembers(List<GroupMemberEntity> groupMembers);

  @Update(onConflict: OnConflictStrategy.replace)
  Future<void> updateGroupMember(GroupMemberEntity groupMember);

  @delete
  Future<void> deleteGroupMember(GroupMemberEntity groupMember);

  @delete
  Future<int> deleteGroupMemberList(List<GroupMemberEntity> list);

  @Query('delete from GroupMemberEntity')
  Future<void> deleteAll();
}
